package com.qianfeng.smartdevice.mapper;

import com.qianfeng.smartdevice.pojo.SysScene;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

/**
 * Created by wenka on 2022/3/25 17:59
 *
 * @author Jackiechan
 * @version 1.0
 * @since 1.0
 */
public interface SysSceneMapper {
    /**
     * 添加新的场景
     * @param sysScene
     */
    @Insert("INSERT INTO sys_scene(scene_name,create_by,create_time)values (#{sceneName},#{createBy},#{createTime})")
    void addSysScene(SysScene sysScene);

    /**
     * 根据用户id和场景名称查询
     * @param userId
     * @param scenceName
     * @return
     */
    @Select("SELECT * FROM sys_scene WHERE create_by=#{userId} AND scene_name=#{scenceName}")
    SysScene findByUserAndName(@Param("userId") Long userId, @Param("scenceName") String scenceName);

    /**
     * 根据场景id更新状态
     * @param sceneId
     * @param status
     * @return
     */
    @Update("UPDATE sys_scene SET status=#{status} WHERE scene_id =#{sceneId} ")
    int updateStatus(@Param("sceneId") Long sceneId, @Param("status") Long status);

    /**
     * 根据id查询场景信息
     * @param id
     * @return
     */
    @Select("SELECT * FROM sys_scene WHERE  scene_id =#{id}")
    SysScene findById(Long id);
}
